<?php
/*********************************************************************
 * ADVERTISEMENT-SHOW CONTROLLER
 * 
 * Author: hthieu1110
 * Date: 12/04/2011 (generated automatically)
*********************************************************************/
require_once dirname(realpath(__FILE__))."./../../config/config.inc.php";

$advertisementId = $_REQUEST['id'];
$adType = $_GET['type'];

try {
	$advertisement = new Advertisement($advertisementId);
  $photos = Advertisement::retrievePhotos($advertisementId);
	$thumbs = Advertisement::retrieveThumbs($advertisementId);

} catch (Exception $e) {
		sessionSetVar('error', 'Unable to get the Advertisement "'.$advertisementId.'".<br/>Error : '.$e->getMessage());
		header('Location:/error.php');
		exit();
}

#build the variables
list($createdAtDate, $createdAtTime) = explode(' ', $advertisement->getCreatedAt());

$email = $advertisement->getEmail();

$telephone = $advertisement->getTelephone();
$telephone = ($telephone != '') ? $telephone : '-';

$date = stringDateValueToText($createdAtDate);

$time = stringTimeValueToText($createdAtTime);

$title = $advertisement->getTitle();

$description = $advertisement->getDescription();

$price = $advertisement->getPrice();
$price = ($price == 0) ? '-' : $price.' €';

$photo = (sizeof($photos) > 0) ? $photos[0] : PHOTOS_URL.'advertisement/noPhoto.jpg' ;

$townCode = $advertisement->getTownCode();

$townName = $advertisement->getTownName();

$categoryName = $advertisement->getCategoryName();

$name = $advertisement->getName();

#template ---------------------------------------------------------------
require_once VIEW_PATH."header.inc.php";
require_once VIEW_PATH."menu.inc.php";
require_once VIEW_PATH."advertisement-show.inc.php";
require_once VIEW_PATH."footer.inc.php";
?>